q = 0
c1 = 0
c2 = 0
c3 = 0
ctot = 0
a = input()
b = a.split(" ")
for i in b:
    if i == "one":
        if c1 == 0:
            c1 = 100
        elif c1 != 0 and c2 != 0:
            c3 = 1
        elif c1 != 0 and c2 == 0:
            c2 = 10
    elif i == "two":
        if c1 == 0:
            c1 = 200
        elif c1 != 0 and c2 != 0:
            c3 = 2
        elif c1 != 0 and c2 == 0:
            c2 = 20
    elif i == "three":
        if c1 == 0:
            c1 = 300
        elif c1 != 0 and c2 != 0:
            c3 = 3
        elif c1 != 0 and c2 == 0:
            c2 = 30
    elif i == "four":
        if c1 == 0:
            c1 = 400
        elif c1 != 0 and c2 != 0:
            c3 = 4
        elif c1 != 0 and c2 == 0:
            c2 = 40
    elif i == "five":
        if c1 == 0:
            c1 = 500
        elif c1 != 0 and c2 != 0:
            c3 = 5
        elif c1 != 0 and c2 == 0:
            c2 = 50
    elif i == "six":
        if c1 == 0:
            c1 = 600
        elif c1 != 0 and c2 != 0:
            c3 = 6
        elif c1 != 0 and c2 == 0:
            c2 = 60
    elif i == "seven":
        if c1 == 0:
            c1 = 700
        elif c1 != 0 and c2 != 0:
            c3 = 7
        elif c1 != 0 and c2 == 0:
            c2 = 70
    elif i == "eight":
        if c1 == 0:
            c1 = 800
        elif c1 != 0 and c2 != 0:
            c3 = 8
        elif c1 != 0 and c2 == 0:
            c2 = 80
    elif i == "nine":
        if c1 == 0:
            c1 = 900
        elif c1 != 0 and c2 != 0:
            c3 = 9
        elif c1 != 0 and c2 == 0:
            c2 = 90
    elif i == "zero":
        if c1 == 0:
            c1 = 123
        elif c1 != 0 and c2 != 0:
            c3 = 123
        elif c1 != 0 and c2 == 0:
            c2 = 123
    else:
        print("Wrong input")
        q = 1
        break
ctot = c1 + c2 + c3
if q == 0:
    c = int(ctot)
    t = c + 1
    d = []
    h = []
    for i in range(2, c):
        for j in range(2, i):
            if i % j == 0:
                d.append(j)
        if len(d) > 0:
            d = []
            continue
        else:
            h.append(i)
            continue
    k = []
    n = []
    while len(n) == 0:
        for j in range(2, t):
            if t % j == 0:
                k.append(j)
        if len(k) > 0:
            k = []
            t += 1
            continue
        else:
            n.append(t)
            break
    if c - h[-1] > n[0] - c:
        print(n[0])
    else:
        print(h[-1])